def maxProfit(prices, fee):
    """计算带手续费的最大股票交易利润"""
    n = len(prices)
    if n == 0:
        return 0
    hold = -prices[0]
    not_hold = 0
    for i in range(1, n):
        prev_hold = hold
        hold = max(prev_hold, not_hold - prices[i])
        not_hold = max(not_hold, prev_hold + prices[i] - fee)
    return not_hold  